﻿using MRMDS_Client;

public class MoveCommand
{
    public string? Type { get; set; }
    public Position StartPosition { get; set; }
    public Position TargetPosition { get; set; }
    public string? OperatorUUID { get; set; }

    public bool Phrase(Command command)
    {
        Type = command.Type;
        if (!command.Args.TryGetValue("StartPosition", out var start))
        {
            return false;
        }
        if (!command.Args.TryGetValue("TargetPosition", out var target))
        {
            return false;
        }
        if (!command.Args.TryGetValue("OperatorUUID", out var id))
        {
            return false;
        }
        StartPosition = (Position)start;
        TargetPosition = (Position)target;
        OperatorUUID = (string?)id;
        return true;
    }

    public Command? Encode()
    {
        var command = new Command(Type??"Undefine");
        command.Args.Add("StartPosition", StartPosition);
        command.Args.Add("TargetPosition", TargetPosition);
        command.Args.Add("OperatorUUID", OperatorUUID?? "Undefine");
        return command;
    }
}